package demo13;

import java.io.File;
import java.io.IOException;
import java.util.Scanner;

/**
 * @author Huangjin
 * @version 1.0
 * describe:
 * @date 2023/3/6 20:20
 */
public class Test05 {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个文件名：");
        String input = sc.next();
        while (true){
            File file1 = new File("./"+input);
            if (file1.exists()){
                System.out.println("该文件已经存在，请重新输入：");
                input = sc.next();
            }else {
                file1.createNewFile();
                System.out.println("文件创建成功！");
                break;
            }
        }

    }
}
